<html xmlns:fn="http://www.w3.org/2003/05/xpath-functions">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style>
             .good {background-color: #3F0;}
             .bad {background-color:#F30;}
         </style></head>
   <body>
      <h1>preparse XQuery Unit Tests</h1>
      <p><b>92% Tests ran successfully</b><br>:Test the parsing and ordering of pipeline steps with XProc.xq
      </p>
      <table border="1">
         <tr>
            <td>test name</td>
            <td>status</td>
            <td>result</td>
            <td>expected</td>
         </tr>
         <tr>
            <td><b>preparse p:group</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:xproc="http://xproc.net/xproc" xmlns:p="http://www.w3.org/ns/xproc" xproc:preparsed="true" name="pipeline">
            <p:input name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="pipeline" port="xproc:stdin"></p:pipe>
            </p:input>
            <p:output name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="!0:pipeline" port="result"></p:pipe>
            </p:output>
            <p:group name="version" xproc:defaultname="!3:pipeline:version" xproc:type="comp">
               <p:identity name="step1" xproc:defaultname="!3:pipeline:version:!1::step1" xproc:type="std">
                  <p:input port="source" primary="true" select="">
                     <p:pipe step="" port=""></p:pipe>
                  </p:input>
                  <p:output port="result" primary="true" select=""></p:output>
               </p:identity>
               <p:count name="step2" xproc:defaultname="!3:pipeline:version:!2::step2" xproc:type="std">
                  <p:input port="source" primary="true" select="">
                     <p:pipe step="!3:pipeline:version:!1::step1" port="result"></p:pipe>
                  </p:input>
                  <p:output port="result" primary="true" select=""></p:output>
               </p:count>
               <p:group name="another" xproc:defaultname="!3:pipeline:version:!3::another" xproc:type="comp">
                  <p:identity name="step1" xproc:defaultname="!3:pipeline:version:!3::another:!1::step1" xproc:type="std">
                     <p:input port="source" primary="true" select="">
                        <p:pipe step="" port=""></p:pipe>
                     </p:input>
                     <p:output port="result" primary="true" select=""></p:output>
                  </p:identity>
                  <p:count name="step2" xproc:defaultname="!3:pipeline:version:!3::another:!2::step2" xproc:type="std">
                     <p:input port="source" primary="true" select="">
                        <p:pipe step="!3:pipeline:version:!3::another:!1::step1" port="result"></p:pipe>
                     </p:input>
                     <p:output port="result" primary="true" select=""></p:output>
                  </p:count>
               </p:group>
            </p:group>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60"></textarea></td>
         </tr>
         <tr>
            <td><b>preparse p:choose</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:xproc="http://xproc.net/xproc" xmlns:p="http://www.w3.org/ns/xproc" xproc:preparsed="true" name="pipeline">
            <p:input name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="pipeline" port="xproc:stdin"></p:pipe>
            </p:input>
            <p:output name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="!0:pipeline" port="result"></p:pipe>
            </p:output>
            <p:choose name="version" xproc:defaultname="!3:pipeline:version" xproc:type="comp">
               <p:when test="//test">
                  <p:identity name="step1" xproc:defaultname="!3:pipeline:version:!1::step1">
                     <p:input port="source" primary="true" select="">
                        <p:document href="file:test/data/alternate_data_1.xml"></p:document>
                     </p:input>
                     <p:output port="result" primary="true" select=""></p:output>
                  </p:identity>
               </p:when>
               <p:otherwise>
                  <p:error name="" xproc:defaultname="!3:pipeline:version:!1::">
                     <p:input port="source" primary="" select=""></p:input>
                     <p:option name="code" select="" value="error code"></p:option>
                  </p:error>
               </p:otherwise>
            </p:choose>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60"></textarea></td>
         </tr>
         <tr>
            <td><b>basic preparse example</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:xproc="http://xproc.net/xproc" xmlns:p="http://www.w3.org/ns/xproc" xproc:preparsed="true" name="pipeline">
            <p:input name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="pipeline" port="xproc:stdin"></p:pipe>
            </p:input>
            <p:output name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="!0:pipeline" port="result"></p:pipe>
            </p:output>
            <p:count name="" xproc:defaultname="!3:pipeline:" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="pipeline" port="source"></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:count>
            <p:identity name="" xproc:defaultname="!4:pipeline:" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="!3:pipeline:" port="result"></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:identity>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60"></textarea></td>
         </tr>
         <tr>
            <td><b>util:pipeline-step-sort 1</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:p="http://www.w3.org/ns/xproc">
            <util:step xmlns:util="http://xproc.net/xproc/util" name="helloworld">
               <p:input port="std-input"></p:input>
               <p:output port="std-output"></p:output>
            </util:step>
            <p:count name="step1">
               <p:input port="step1-input">
                  <p:pipe step="helloworld" port="std-input"></p:pipe>
               </p:input>
               <p:output port="step1-output"></p:output>
            </p:count>
            <p:identity name="step2">
               <p:input port="step2-input">
                  <p:pipe step="step1" port="step1-output"></p:pipe>
               </p:input>
               <p:output port="step2-output"></p:output>
            </p:identity>
            <p:count name="step3">
               <p:input port="step3-input">
                  <p:pipe step="step2" port="step2-output"></p:pipe>
               </p:input>
            </p:count>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:p="http://www.w3.org/ns/xproc">
            <util:step xmlns:util="http://xproc.net/xproc/util" name="helloworld">
               <p:input port="std-input"></p:input>
               <p:output port="std-output"></p:output>
            </util:step>
            <p:count name="step1">
               <p:input port="step1-input">
                  <p:pipe step="helloworld" port="std-input"></p:pipe>
               </p:input>
               <p:output port="step1-output"></p:output>
            </p:count>
            <p:identity name="step2">
               <p:input port="step2-input">
                  <p:pipe step="step1" port="step1-output"></p:pipe>
               </p:input>
               <p:output port="step2-output"></p:output>
            </p:identity>
            <p:count name="step3">
               <p:input port="step3-input">
                  <p:pipe step="step2" port="step2-output"></p:pipe>
               </p:input>
            </p:count>
         </p:pipeline>
      </textarea></td>
         </tr>
         <tr>
            <td><b>util:pipeline-step-sort 2</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:p="http://www.w3.org/ns/xproc">
            <util:step xmlns:util="http://xproc.net/xproc/util" name="helloworld">
               <p:input port="std-input" name="std-input"></p:input>
               <p:output port="std-output" name="std-output"></p:output>
            </util:step>
            <p:identity name="step1">
               <p:input port="step1"></p:input>
               <p:output port="step2-output"></p:output>
            </p:identity>
            <p:count name="step2">
               <p:input port="step2"></p:input>
            </p:count>
            <p:count name="step3">
               <p:input port="std-input"></p:input>
               <p:output port="test1-output"></p:output>
            </p:count>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60"></textarea></td>
         </tr>
         <tr>
            <td><b>preparse + parse 1</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">import module namespace xproc = "http://xproc.net/xproc"
                        at "src/xquery/xproc.xqm";
import module namespace util = "http://xproc.net/xproc/util"
                        at "src/xquery/util.xqm";
import module namespace std = "http://xproc.net/xproc/std"
                        at "src/xquery/std.xqm";
import module namespace ext = "http://xproc.net/xproc/ext"
                        at "src/xquery/ext.xqm";
import module namespace opt = "http://xproc.net/xproc/opt"
                        at "src/xquery/opt.xqm";
let $O0 := &lt;test/&gt; 
let $pipeline := &lt;p:pipeline xmlns:xproc="http://xproc.net/xproc" xmlns:p="http://www.w3.org/ns/xproc" xproc:preparsed="true" name="helloworld"&gt;&lt;p:identity name="step1" xproc:defaultname="!1:helloworld:step1" xproc:type="std"&gt;&lt;p:input port="source" primary="true" select=""&gt;&lt;p:pipe step="helloworld" port=""/&gt;&lt;/p:input&gt;&lt;p:output port="result" primary="true" select=""/&gt;&lt;/p:identity&gt;&lt;p:count name="step2" xproc:defaultname="!2:helloworld:step2" xproc:type="std"&gt;&lt;p:input port="source" primary="true" select=""&gt;&lt;p:pipe step="!1:helloworld:step1" port="result"/&gt;&lt;/p:input&gt;&lt;p:output port="result" primary="true" select=""/&gt;&lt;/p:count&gt;&lt;p:count name="step3" xproc:defaultname="!3:helloworld:step3" xproc:type="std"&gt;&lt;p:input port="source" primary="true" select=""&gt;&lt;p:pipe step="!2:helloworld:step2" port="result"/&gt;&lt;/p:input&gt;&lt;p:output port="result" primary="true" select=""/&gt;&lt;/p:count&gt;&lt;/p:pipeline&gt; 
let $steps := ( "!1:helloworld:step1", "!2:helloworld:step2", "!3:helloworld:step3", "") return util:step-fold($pipeline,$steps, saxon:function("xproc:evalstep", 3),($O0,""))</textarea></td>
            <td><textarea name="content" rows="6" cols="60"></textarea></td>
         </tr>
         <tr>
            <td><b>eval explicit binding prepares 1a</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:xproc="http://xproc.net/xproc" xmlns:p="http://www.w3.org/ns/xproc" xproc:preparsed="true" name="main">
            <p:input name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="main" port="xproc:stdin"></p:pipe>
            </p:input>
            <p:output name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="!0:main" port="result"></p:pipe>
            </p:output>
            <p:count name="" xproc:defaultname="!3:main:" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="main" port="source"></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:count>
            <p:identity name="" xproc:defaultname="!4:main:" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="!3:main:" port="result"></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:identity>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60"></textarea></td>
         </tr>
         <tr>
            <td><b>eval explicit binding prepares 1b</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:xproc="http://xproc.net/xproc" xmlns:p="http://www.w3.org/ns/xproc" xproc:preparsed="true" name="main">
            <p:input name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="" port=""></p:pipe>
            </p:input>
            <p:output name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="" port=""></p:pipe>
            </p:output>
            <p:count name="step1" xproc:defaultname="!3:main:step1" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="main" port=""></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:count>
            <p:identity name="step2" xproc:defaultname="!4:main:step2" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="!3:main:step1" port="result"></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:identity>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60"></textarea></td>
         </tr>
         <tr>
            <td><b>eval explicit binding prepares 1c</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:xproc="http://xproc.net/xproc" xmlns:p="http://www.w3.org/ns/xproc" xproc:preparsed="true" name="main">
            <p:input name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="" port=""></p:pipe>
            </p:input>
            <p:output name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="" port=""></p:pipe>
            </p:output>
            <p:identity name="" xproc:defaultname="!3:main:" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="main" port=""></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:identity>
            <p:count name="" xproc:defaultname="!4:main:" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="!3:main:" port="result"></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:count>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60"></textarea></td>
         </tr>
         <tr>
            <td><b>eval explicit binding prepares 1d</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:xproc="http://xproc.net/xproc" xmlns:p="http://www.w3.org/ns/xproc" xproc:preparsed="true" name="main">
            <p:input name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="" port=""></p:pipe>
            </p:input>
            <p:output name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="" port=""></p:pipe>
            </p:output>
            <p:identity name="step1" xproc:defaultname="!3:main:step1" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="main" port=""></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:identity>
            <p:count name="step2" xproc:defaultname="!4:main:step2" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="!3:main:step1" port="result"></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:count>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60"></textarea></td>
         </tr>
         <tr>
            <td><b>eval explicit binding prepares 1e</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:xproc="http://xproc.net/xproc" xmlns:p="http://www.w3.org/ns/xproc" xproc:preparsed="true" name="main">
            <p:input name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="main" port="xproc:stdin"></p:pipe>
            </p:input>
            <p:output name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="!0:main" port="result"></p:pipe>
            </p:output>
            <p:identity name="step1" xproc:defaultname="!3:main:step1" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="main" port="source"></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:identity>
            <p:count name="step2" xproc:defaultname="!4:main:step2" xproc:type="std">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="!3:main:step1" port="result"></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:count>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60"></textarea></td>
         </tr>
         <tr>
            <td><b>eval explicit binding prepares 2: non-existent step should throw error</b></td>
            <td>
               <div class="bad">failed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:p="http://www.w3.org/ns/xproc" name="pipeline">
            <p:input port="source">
               <p:pipe step="" port=""></p:pipe>
            </p:input>
            <p:output port="result">
               <p:pipe step="" port=""></p:pipe>
            </p:output>
            <p:identity xmlns:xproc="http://xproc.net/xproc" name="" xproc:defaultname="!3:pipeline:">
               <p:input port="source" primary="true" select=""></p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:identity>
            <p:count xmlns:xproc="http://xproc.net/xproc" name="" xproc:defaultname="!4:pipeline:">
               <p:input port="source" primary="true" select=""></p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </p:count>
            <err:error xmlns:err="http://www.w3.org/ns/xproc-error" message="general static error thrown during explicit naming: p:thisstepdoesnotexist is an unknown element"></err:error>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60">error</textarea></td>
         </tr>
         <tr>
            <td><b>eval explicit binding prepares 3 with optional and extension step</b></td>
            <td>
               <div class="good">passed </div>
            </td>
            <td><textarea name="content" rows="6" cols="60">
         <p:pipeline xmlns:xproc="http://xproc.net/xproc" xmlns:p="http://www.w3.org/ns/xproc" xproc:preparsed="true" name="pipeline">
            <p:input name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="" port=""></p:pipe>
            </p:input>
            <p:output name="" xproc:defaultname="" xproc:type="comp">
               <p:pipe step="" port=""></p:pipe>
            </p:output>
            <p:uuid name="" xproc:defaultname="!3:pipeline:" xproc:type="opt">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="pipeline" port=""></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
               <p:option name="match" select="" value=""></p:option>
            </p:uuid>
            <ext:test xmlns:ext="http://xproc.net/xproc/ext" name="" xproc:defaultname="!4:pipeline:" xproc:type="ext">
               <p:input port="source" primary="true" select="">
                  <p:pipe step="!3:pipeline:" port="result"></p:pipe>
               </p:input>
               <p:output port="result" primary="true" select=""></p:output>
            </ext:test>
         </p:pipeline>
      </textarea></td>
            <td><textarea name="content" rows="6" cols="60"></textarea></td>
         </tr>
      </table>
      
      failed: 1 /  success: 12 / total: 13
      <hr>
      <p style="text-align:right"><i>2008-06-29T15:49:08.626+02:00 generated by <a href="http://code.google.com/p/xprocxq">XQuery Unit Test</a>, by jim.fuller@webcomposite.com</i></p>
   </body>
</html>